package com.csun.nusing.ui.fragment;

import android.content.Intent;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.GridView;
import android.widget.ImageView;

import com.csun.nusing.R;
import com.csun.nusing.familypresenter.FragmentFamilyOldrestPresenter;
import com.csun.nusing.presenter.inter.IBase;
import com.csun.nusing.ui.familyactivity.FamilyAddOlderActivity;

public class FamilyOlderFragment extends
		BaseFragment<FragmentFamilyOldrestPresenter> implements IBase {

	public static final int AddOlderCode = 21;// 跳转添加界面
	private ImageView searchiv;
	private GridView recycleView;
	private ImageView oldadd_iv;

	public FamilyOlderFragment() {
	}

	public static FamilyOlderFragment newInstance() {
		return new FamilyOlderFragment();
	}

	@Override
	public int getContentViewId() {
		return R.layout.fragment_family_oldrest;
	}

	// findView
	@Override
	public void initSubViews(View view) {
		super.initSubViews(view);
		findView(view);
		controlView();
	}

	/**
	 * 控制点击事件
	 * 
	 * @Description: TODO
	 * @param
	 * @return void
	 * @throws
	 * @author fzq
	 * @date 2017-10-25
	 */
	private void controlView() {
	}

	/**
	 * 控件
	 * 
	 * @Description: TODO
	 * @param @param view
	 * @return void
	 * @throws
	 * @author fzq
	 * @date 2017-10-20
	 */
	private void findView(View view) {
		recycleView = view
				.findViewById(R.id.fragment_family_oldrest_gv);
		oldadd_iv = view.findViewById(R.id.oldadd_iv);
		oldadd_iv.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(getActivity(),
						FamilyAddOlderActivity.class);
				startActivityForResult(intent, 0x11);
			}
		});
	}

	// 交给presenter处理数据逻辑
	@Override
	public void initData() {
		super.initData();
		mPresenter.getOldListDate(getActivity(), recycleView);
	}

	@Override
	protected FragmentFamilyOldrestPresenter getPresenter() {
		return new FragmentFamilyOldrestPresenter(this);
	}

	/**
	 * 监听跳转的返回,在添加老人后返回,界面数据改变
	 */
	@Override
	public void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		Log.e("fzq","----------");
		mPresenter.getOldListDate(getActivity(), recycleView);
	}

}
